define(['jquery'],() => {
	class Header {
		constructor() {
		    this.loadHtml().then(() =>{
			this.calcarcount()	
			})
			
		}
		loadHtml () {
			// console.log('load')
			return new Promise(resolve => {
			$('header').load('/html/modules/header.html',() => {
				resolve()
			})
			
			})
		}
		calcarcount (){
			let count = 0
			let cart = localStorage.getItem('cart')
			
			console.log($('#trolley_num'))
			if(cart){
				cart = JSON.parse(cart)
				count = cart.reduce((num,shop) => {
					return num +shop.count
				},0)
			}
			$('#numttt').html(count)
			$('#shop_car_num').html(count)
			$('#trolley_num').html(count)
		}
	}
	return new Header
})